package com.jwater.console.service;

import java.io.File;
import java.util.List;

import com.jwater.console.model.Result;
import com.jwater.console.model.TreeNode;
import com.jwater.core.manager.common.model.*;

/**
 * @description:
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public interface ConsoleService {
    /**
     * 检查连接是否连着的
     *
     * @return
     */
    public boolean checkConnect();

    /**
     * 登录验证
     *
     * @param regionName
     * @param username
     * @param password
     * @param token
     * @return
     * @throws Exception
     */
    public boolean login(String regionName, String username, String password, String token) throws Exception;

    /**
     * 退出登录
     *
     * @param token
     * @throws Exception
     */
    public void logout(String token) throws Exception;

    /**
     * 是否存在token，判断用户登录是否合法
     *
     * @param token
     * @return
     * @throws Exception
     */
    public boolean existToken(String token) throws Exception;

    /**
     * 获取配置列表
     *
     * @return
     * @throws Exception
     */
    public List<String> getConfList() throws Exception;

    /**
     * 获取配置内容
     *
     * @param path
     * @return
     * @throws Exception
     */
    public String getConfContent(String path) throws Exception;

    /**
     * 保存配置内容
     *
     * @param path
     * @param content
     * @throws Exception
     */
    public void saveConfContent(String path, String content) throws Exception;

    /**
     * 新建配置文件
     *
     * @param sys
     * @param regionName
     * @param deployName
     * @param fileName
     * @throws Exception
     */
    public void newConf(boolean sys, String regionName, String deployName, String fileName) throws Exception;

    /**
     * 删除配置文件
     *
     * @param path
     * @throws Exception
     */
    public void deleteConf(String path) throws Exception;

    /**
     * 获取管理进程列表
     *
     * @return
     * @throws Exception
     */
    public List<MasterInfo> getMasterList() throws Exception;

    /**
     * 重启控制台
     *
     * @throws Exception
     */
    public void rebootConsole() throws Exception;

    /**
     * 启动管理进程
     *
     * @param index
     * @throws Exception
     */
    public void startMaster(int index) throws Exception;

    /**
     * 停止管理进程
     *
     * @param index
     * @throws Exception
     */
    public void stopMaster(int index) throws Exception;

    /**
     * 获取主机列表
     *
     * @return
     * @throws Exception
     */
    public List<HostInfo> getHostList() throws Exception;

    /**
     * 启动代理进程
     *
     * @param host
     * @throws Exception
     */
    public void startProxy(String host) throws Exception;

    /**
     * 停止代理进程
     *
     * @param host
     * @throws Exception
     */
    public void stopProxy(String host) throws Exception;

    /**
     * 获取菜单列表
     *
     * @param regionName
     * @return
     * @throws Exception
     */
    public String getMenuList(String regionName) throws Exception;

    /**
     * 保存菜单
     *
     * @param regionName
     * @param content
     * @throws Exception
     */
    public void saveMenu(String regionName, String content) throws Exception;

    /**
     * 获取部署包列表
     *
     * @param regionName
     * @return
     * @throws Exception
     */
    public List<String> getDeployList(String regionName) throws Exception;

    /**
     * 部署应用
     *
     * @param path
     * @param regionName
     * @param deployName
     * @param keepConf
     * @param fileName
     * @param tmpFile
     * @throws Exception
     */
    public void deploy(String path, String regionName, String deployName, String keepConf, String fileName,
                       File tmpFile) throws Exception;

    /**
     * 移除部署包
     *
     * @param regionName
     * @param deployName
     * @throws Exception
     */
    public void removeDeploy(String regionName, String deployName) throws Exception;

    /**
     * 获取工作进程列表
     *
     * @param regionName
     * @return
     * @throws Exception
     */
    public List<WorkerInfo> getWorkerList(String regionName) throws Exception;

    /**
     * 启动工作进程
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param workerName
     * @param index
     * @throws Exception
     */
    public void startWorker(String regionName, String deployName, String groupName, String workerName, int index)
            throws Exception;

    /**
     * 停止工作进程
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param workerName
     * @param index
     * @throws Exception
     */
    public void stopWorker(String regionName, String deployName, String groupName, String workerName, int index,
                           boolean isForce)
            throws Exception;

    /**
     * 获取进程配置文件列表
     *
     * @param regionName
     * @param deployName
     * @return
     * @throws Exception
     */
    public List<String> getWorkerConfList(String regionName, String deployName) throws Exception;

    /**
     * 获取配置根路径列表
     *
     * @param regionName
     * @param deployName
     * @return
     * @throws Exception
     */
    public List<String> getWorkerConfRoot(String regionName, String deployName) throws Exception;

    /**
     * 获取离线任务列表
     *
     * @param regionName
     * @return
     * @throws Exception
     */
    public List<JobInfo> getJobList(String regionName) throws Exception;

    /**
     * 启动离线任务调度器
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param jobName
     * @throws Exception
     */
    public void startJob(String regionName, String deployName, String groupName, String jobName) throws Exception;

    /**
     * 停止离线任务调度器
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param jobName
     * @throws Exception
     */
    public void stopJob(String regionName, String deployName, String groupName, String jobName) throws Exception;

    /**
     * 运行离线任务
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param jobName
     * @param time
     * @throws Exception
     */
    public void runJob(String regionName, String deployName, String groupName, String jobName, long time)
            throws Exception;

    /**
     * 杀死离线任务
     *
     * @param regionName
     * @param deployName
     * @param groupName
     * @param jobName
     * @throws Exception
     */
    public void killJob(String regionName, String deployName, String groupName, String jobName) throws Exception;

    /**
     * 获取日志内容
     *
     * @param host
     * @param path
     * @return
     * @throws Exception
     */
    public String getLogContent(String host, String path) throws Exception;

    /**
     * 清空日志内容
     *
     * @param host
     * @param path
     * @throws Exception
     */
    public void clearLogContent(String host, String path) throws Exception;

    /**
     * 下载日志内容
     *
     * @param host
     * @param path
     * @return
     * @throws Exception
     */
    public File downLogContent(String host, String path) throws Exception;

    /**
     * 获取日志文件列表
     *
     * @param regionName
     * @param host
     * @param path
     * @return
     * @throws Exception
     */
    public List<String> getHostLogList(String regionName, String host, String path) throws Exception;

    /**
     * 重新加载worker、job配置信息
     *
     * @param regionName
     * @throws Exception
     */
    public void loadConf(String regionName) throws Exception;

    /**
     * 获取主机列表
     *
     * @return
     * @throws Exception
     */
    public List<NodeInfo> getNodeInfos() throws Exception;

    /**
     * 获取java进程列表
     *
     * @param host
     * @return
     * @throws Exception
     */
    public List<JvmInfo> getJvmInfo(String host) throws Exception;

    /**
     * @param host
     * @param type
     * @param pid
     * @return
     * @throws Exception
     */
    public File downCmdJvmInfo(String host, String type, String pid) throws Exception;

    /**
     * 目录树形列表
     *
     * @param host
     * @param path
     * @return
     * @throws Exception
     */
    public List<TreeNode> fileTreeNode(String host, String path) throws Exception;

    /**
     * 文件列表
     *
     * @param host
     * @param path
     * @return
     * @throws Exception
     */
    public List<FileInfo> fileInfoList(String host, String path) throws Exception;

    /**
     * 上传文件
     *
     * @param host
     * @param path
     * @param fileName
     * @param tmpFile
     * @throws Exception
     */
    public void uploadFile(String host, String path, String fileName, File tmpFile) throws Exception;

    /**
     * 删除文件
     *
     * @param host
     * @param path
     * @throws Exception
     */
    public void deleteFile(String host, String path) throws Exception;

    /**
     * 获取所有系统信息
     *
     * @return
     * @throws Exception
     */
    public List<SystemInfo> getAllSystemInfo() throws Exception;

    /**
     * 移除报警信息
     *
     * @param type
     */
    public void removeAlarmInfo(String type);

    /**
     * 获取所有报警信息
     *
     * @return
     */
    public List<AlarmInfo> getAllAlarmInfo();

    /**
     * 获取安装包信息
     *
     * @return
     */
    public List<PackageInfo> getPackageInfo();

    /**
     * 获取安装包信息
     *
     * @return
     */
    public List<DeployInfo> getDeployInfo(String regionName) throws Exception;

    /**
     * 创建安装包目录
     *
     * @param regionName
     * @param deployName
     * @throws Exception
     */
    public void createDeployDir(String regionName, String deployName) throws Exception;

    /**
     * 获取版本列表
     *
     * @param regionName
     * @param deployName
     * @return
     * @throws Exception
     */
    public List<String> getDeployVersionList(String regionName, String deployName) throws Exception;

    /**
     * 改变部署信息
     *
     * @param regionName
     * @param deployName
     * @param key
     * @param value
     * @throws Exception
     */
    public void changeDeployProp(String regionName, String deployName, String key, String value) throws Exception;

    /**
     * @param gatewayGroupName
     * @param gatewayWorkerName
     * @param gatewayIndex
     * @param gatewayRegionName
     * @param gatewayDeployName
     * @return
     */
    public List<GatewayProxyInfo> getGatewayProxyInfo(String gatewayGroupName, String gatewayWorkerName, int gatewayIndex,
                                                      String gatewayRegionName, String gatewayDeployName);
}